//
//  MorePageController.m
//  WashForU
//
//  Created by 王俊 on 15/11/25.
//  Copyright © 2015年 王俊. All rights reserved.
//

#import "MorePageController.h"

@interface MorePageController ()

@end

@implementation MorePageController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self customViewSetUp];
    [self customConstrainsAdd];
}
/*****************添加视图组件********************/
- (void)customViewSetUp
{
    self.titleLabel.text      = @"更多";
    self.titleLabel.font      = [UIFont CustomFont:20];
    self.titleLabel.textColor = [UIColor GrayColor_88];
    _moreInfo                 = [[NSArray alloc]initWithObjects:@"联系客服",
                                                                @"常见问题",
                                                                @"服务范围",
                                                                @"关于我们",
                                                                @"用户协议",
                                                                @"意见反馈", nil];
    _tableView                  = [[UITableView alloc]init];
    _tableView.dataSource       = self;
    _tableView.delegate         = self;
    _tableView.backgroundColor  = [UIColor clearColor];
    
    [self.tableView setExtraCellLineHidden];
    [self.view addSubview:_tableView];
    
  
    
}
/*******************添加约束**********************/
- (void)customConstrainsAdd
{
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.equalTo(self.view);
        make.top.equalTo(self.upView.mas_bottom).offset(1);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _moreInfo.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MoreInfoCell *cell = [MoreInfoCell initWithTitle:_moreInfo[indexPath.row] andImageName:_moreInfo[indexPath.row]];
    return cell;
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0: [self showAlertView];
            break;
        case 1: [self showQeustionPage];
            break;
        case 2: [self showServiceRangePage];
            break;
        case 3: [self showAboutUsPage];
            break;
        case 4: [self showProtocolPage];
            break;
        case 5:[self showFeebackPage];
            break;
        default:
            break;
    }

    
}

- (void)showFeebackPage
{
    FeebackPageController *vc = [[FeebackPageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}

- (void)showServiceRangePage
{
    ServiceRangePageController *vc = [[ServiceRangePageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}
- (void)showQeustionPage
{
    QeustionPageController *vc = [[QeustionPageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}
- (void)showProtocolPage
{
    ProtocolPageController *vc = [[ProtocolPageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}


- (void)showAboutUsPage
{
    AboutUsPageController *vc = [[AboutUsPageController alloc]init];
    [self.navigationController pushViewController:vc animated:true];
    
}

- (void)showAlertView
{
    NSString  *message = NSLocalizedString(@"确定要拨打热线吗？", nil);
    NSString  *cancelButtonTitle = NSLocalizedString(@"取消", nil);
    NSString  *comfirmButtonTitle = NSLocalizedString(@"确定", nil);
    
    UIAlertController   *contactReminderAlert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction       *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"取消取消");
    }];
    UIAlertAction       *comfirmAction = [UIAlertAction actionWithTitle:comfirmButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //这里调用ihpone手机拨号功能
        NSLog(@"确认确认");
    }];
    
    [contactReminderAlert addAction:comfirmAction];
    [contactReminderAlert addAction:cancelAction];
    [self presentViewController:contactReminderAlert animated:true completion:nil];
    
}



@end
